<?php

//防止恶意调用
if (!defined('IN_MOD'))
{
    die('Hacking attempt');
}

// 自定义模块，自定义区块，自定义配置
// 自定义栏目，自定义插件，自定义扩展，自定义单页，自定义分类

define('MODULEPARA_BASE_PATH',str_replace('\\','/',realpath(dirname(__FILE__).'/'))."/");
include_once (MODULEPARA_BASE_PATH."./service/MysqliService.class.php"); //mysql类
global $cjdb,$moduledb,$configdbi,$moduletpl,$moduleupload,$moduleimage,$fanyi,$moduleredis;
$moduledb=$cjdb=new ModuleMysqli($configdbi['host'],$configdbi['user'],$configdbi['pass'],'utf8',$configdbi['db']);
//获取模板引擎加载类
include MODULEPARA_PATH."/modulepara-".VERSION_NUMBER."/service/tplvar/TemplateService.class.php";
include MODULEPARA_PATH."/modulepara-".VERSION_NUMBER."/service/tplvar/CompileService.class.php";
$modulecachedir = $configinfo['tplok'] == 1 ? $configinfo['tplurl'] : MODULEPARA_PATH;
$moduletplconfig = array('templateDir'=>MODULEPARA_PATH."/config/datatpl/",
'compileDir'=>$modulecachedir."/configdata/modulecache/",
'autotplDir'=>$modulecachedir."/configdata/modulecache/autotpl/");
$moduletpl = new TemplateModule($moduletplconfig);
//包含一个文件上传类中的上传类
include MODULEPARA_BASE_PATH."./service/FileuploadService.class.php";
$moduleupload = new fileupload();
// 百度自动翻译插件
// $text=$fanyi->fanyi($text,'auto','auto');
require_once MODULEPARA_BASE_PATH.'./service/fanyi/FanyiService.lib.php';
$fanyi=new BaiduFanyi();
// 加载生成缩略图
include_once MODULEPARA_BASE_PATH.'./service/ImgthumbService.class.php';
$moduleimage = new ImgLib();
// 数据分页类
include MODULEPARA_BASE_PATH."./service/PageService.class.php";
//echo $moduleimage->thumb("test.jpg",300,300);// 留白
//echo $moduleimage->thumb("test.jpg",300,300,1);// 裁剪
// Redis缓存技术
if($configinfo['redisok'] == 1)
{
	require_once MODULEPARA_BASE_PATH.'./service/RedisService.class.php';
	try {
		$moduleredis = new RedisCluster();
		$moduleredis->connect(array('host'=>'127.0.0.1','port'=>6379));
		$moduleredis->getRedis()->ping();
	} catch (Exception $e) {
		//echo $e->getMessage();
		$configinfo['redisok'] = 0;// 未连接Redis时关闭缓存
		//die(); // 终止异常
	}
}
// 获取模板引擎数据
function getloadtpldata($tplname='', $tpldata=array(), $htmlcontent='', $tpl=0, $moduleid=0)
{
	global $moduletpl;
	global $lang;
	global $_MGPC_POST,$_MGPC_GET,$_MGPC_REQ,$_MGPC_COOKIE,$_MGPC_SESSION,$configlang,$configinfo,$configblock,$configcommon,$configmember,$configbase,$configsystem,$configindex,$configother;
	
	$moduleid = $moduleid ? $moduleid : $configinfo['moduleid'];
	
	$tpldata['lang'] = $lang;
	$tpldata['_MGPC_POST'] = $_MGPC_POST;
	$tpldata['_MGPC_GET'] = $_MGPC_GET;
	$tpldata['_MGPC_REQ'] = $_MGPC_REQ;
	$tpldata['_MGPC_POST'] = $_MGPC_POST;
	$tpldata['_MGPC_COOKIE'] = $_MGPC_COOKIE;
	$tpldata['_MGPC_SESSION'] = $_MGPC_SESSION;
	$tpldata['configlang'] = $configlang;
	$tpldata['configinfo'] = $configinfo;
	$tpldata['configblock'] = $configblock;
	$tpldata['configcommon'] = $configcommon;
	$tpldata['configmember'] = $configmember;
	$tpldata['configbase'] = $configbase;
	$tpldata['configsystem'] = $configsystem;
	$tpldata['configindex'] = $configindex;
	$tpldata['configother'] = $configother;
	
	// 模板配置
	$moduletpl->setConfig('templateDir', MODULEPARA_PATH."/config/datatpl/".$moduleid."/");
	$modulecachedir = $configinfo['tplok'] == 1 ? $configinfo['tplurl'] : MODULEPARA_PATH;
	$moduletpl->setConfig('compileDir', $modulecachedir."/configdata/modulecache/".$moduleid."/");
	$moduletpl->setConfig('autotplDir', $modulecachedir."/configdata/modulecache/autotpl/".$moduleid."/");
	
	// 加载模板程序配置
	if($configinfo['tplok'] == 1)
	{
		if($tpl == 1)
		{
			$moduletpl->setConfig('templateDir', $configinfo['tplurl']."/config/datatpl/".$moduleid."/");
		}
	}
	
	foreach($tpldata as $key=>$val)
	{
		$moduletpl->assign($key, $val);	
	}
	
	$datahtml = $moduletpl->show($tplname,$htmlcontent);
	
	return $datahtml;
}

// 获取当前分类的顶级分类 支持三级分类查询
function gettopclass($tablename='', $classid=0, $classidname='', $bigclassname='', $colseTop = 0)
{
	global $cjdb;
	
	if($colseTop < 1)$modulewhere = "index_num != '自定义区块' and index_num != '自定义配置' and index_num != '自定义扩展' and";// 关闭顶级分类为自定义区块和自定义配置
	$sql="select * from $tablename where $modulewhere $classidname = '$classid'";
	$arr=$cjdb->getRow($sql);
	
	if(!empty($arr[$bigclassname]))
	{
		$sql2="select * from $tablename where $modulewhere $classidname = '$arr[$bigclassname]'";
		$arr2=$cjdb->getRow($sql2);

		if(is_array($arr2))
		{
			if(!empty($arr2[$bigclassname]))
			{
				$sql3="select * from $tablename where $modulewhere $classidname = '$arr2[$bigclassname]'";
				$arr3=$cjdb->getRow($sql3);
				
				if(is_array($arr3))
				{
					return $arr3[$classidname];
				}else{
					return $arr2[$classidname];		
				}
				
			}else{
				return $arr2[$classidname];	
			}
		}else{
			return $arr[$classidname];
		}
	
	}else{
		$returnID = !empty($arr) ? $arr[$classidname] : 0;
		return $returnID;	
	}
}

// 获取当前分类的所有上级分类 支持三级分类查询
function getparentclass($tablename='', $classid=0, $classidname='', $bigclassname='')
{
	global $cjdb;
	
	$modulewhere = "index_num != '自定义区块' and index_num != '自定义配置' and index_num != '自定义扩展' and";// 关闭顶级分类为自定义区块和自定义配置
	$sql="select * from $tablename where $modulewhere $classidname = '$classid'";
	$arr=$cjdb->getRow($sql);
	
	if(!empty($arr[$bigclassname]))
	{
		$sql2="select * from $tablename where $modulewhere $classidname = '$arr[$bigclassname]'";
		$arr2=$cjdb->getRow($sql2);

		if(is_array($arr2))
		{
			if(!empty($arr2[$bigclassname]))
			{
				$sql3="select * from $tablename where $modulewhere $classidname = '$arr2[$bigclassname]'";
				$arr3=$cjdb->getRow($sql3);
				
				if(is_array($arr3))
				{
					return array("class1" => $arr3, "class2" => $arr2, "class3" => $arr, "classtype" => 3);	
				}else{
					return array("class1" => $arr2, "class2" => $arr, "classtype" => 2);	
				}
				
			}else{
				return array("class1" => $arr2, "class2" => $arr, "classtype" => 2);	
			}
		}else{
			return array("class1" => $arr, "classtype" => 2);	
		}
	
	}else{
		return array("class1" => $arr, "classtype" => 1);	
	}
}

// 大于三级分类时根据当前分类获取所有上级分类 支持无限级分类递归查询
function getparentclassall($columnid=0,&$parentclass=array())
{
	global $configinfo;
	
	$columninfo = columninfo($configinfo['ecs_article_cat'],$columnid,$configinfo['cat_id']);
	
	if(!empty($columninfo[$configinfo['parent_id']]))
	{
		$parentcolumn = columninfo($configinfo['ecs_article_cat'],$columninfo[$configinfo['parent_id']],$configinfo['cat_id']);
		
		if(is_array($parentcolumn))
		{
			$parentclass[] = $parentcolumn[$configinfo['cat_id']];
			getparentclassall($parentcolumn[$configinfo['cat_id']],$parentclass);
		}
	}
	
	return $parentclass;	
}

// 大于三级分类时根据当前分类获取上级三级分类 支持无限级分类查询
function getparentclass3($columnid=0)
{
	global $configinfo;
	
	$columnid3 = $columnid;
	
	$columninfo = columninfo($configinfo['ecs_article_cat'],$columnid,$configinfo['cat_id']);
	if($columninfo[$configinfo['classtype']] > 3)
	{
		$patharr = getstrtoarr("-", $columninfo[$configinfo['cat_path']]);
		$columnid3 = $patharr[3];
	}
	
	return $columnid3;	
}

// 合并当前一层分类组与二层分类组
function getTwoClassGroup($list=array(), $list2=array(), $classidname="", $bigclassname="")
{
	// 归类二级分类组
	$ids2 = "";
	$resList2 = array();
	foreach($list2 as $key2=>$val2)
	{
		$ids2 .= ",".$val2[$classidname];
		$resList2[$val2[$bigclassname]][] = $val2;
	}
	
	// 合并一级分类组和二级分类组
	$ids1 = "";
	$resList = array();
	foreach($list as $key=>$val)
	{
		$ids1 .= ",".$val[$classidname];
		$resList[$key] = $val;
		if($resList2[$val[$classidname]])
		{
			$resList[$key]["list2"] = $resList2[$val[$classidname]];
		}
	}
	
	$ids = delstrq($ids1.$ids2);
	
	return array("list" => $resList, "ids" => $ids);
}

// 获取当前分类组ID集
function getClassGroupIDS($list=array(), $classidname="")
{
	$ids = "";
	foreach($list as $key=>$val)
	{
		$ids .= ",".$val[$classidname];
	}
	
	$ids = delstrq($ids);
	
	return $ids;	
}

// 获取当前分类的所有下级分类 支持三级分类查询
function getbottomclass($tablename='', $classid=0, $classidname='', $bigclassname='', $idsok = 0, $where = "")
{
	global $cjdb;
	
	if($where)$whereok = "and $where";
	$sql="select * from $tablename where $bigclassname in($classid) $whereok";
	$list=$cjdb->getAll($sql);
	if(!empty($list))
	{
		$ids1 = getClassGroupIDS($list, $classidname);
		$sql="select * from $tablename where $bigclassname in($ids1) $whereok";
		$list2=$cjdb->getAll($sql);
	}
	
	// 重组一级分类组和二级分类组
	$ids = $classid;
	$catelist = array();
	if(!empty($list))
	{
		if(!empty($list2))
		{
			// 合并一层分类组和二层分类组
			$twoClassGroup = getTwoClassGroup($list, $list2, $classidname, $bigclassname);
			$catelist = $twoClassGroup['list'];
			$ids .= ",".$twoClassGroup['ids'];
		}else{
			$catelist = $list;
			$ids .= ",".$ids1;
		}	
	}
		
	// 统计层级分类总数
	$listdata = array();
	$listdata['count'] = count($catelist);
	$listdata['list'] = $catelist;
	foreach($listdata['list'] as $key=>$val)
	{
		if($val['list2'])
		{
			$listdata['list'][$key]['count'] = count($val['list2']);
		}else{
			$listdata['list'][$key]['count'] = 0;	
		}
	}
	
	if($idsok == 1)
	{
		$resdata = $ids;	
	}else{
		$resdata = array('list' => $listdata, 'ids' => $ids);	
	}
	
	return $resdata;
}

// 获取当前分类的分类信息，为空时自动获取上级分类信息 支持三级分类查询
function getclassinfo($tablename='', $classid=0, $classidname='', $bigclassname='', $infofield='')
{
	global $cjdb;
	
	$modulewhere = "index_num != '自定义区块' and index_num != '自定义配置' and index_num != '自定义扩展' and";// 关闭顶级分类为自定义区块和自定义配置
	$sql="select * from $tablename where $modulewhere $classidname = '$classid'";
	$arr=$cjdb->getRow($sql);
	
	if(!empty($arr[$bigclassname]) && empty($arr[$infofield]))
	{
		$sql2="select * from $tablename where $modulewhere $classidname = '$arr[$bigclassname]'";
		$arr2=$cjdb->getRow($sql2);

		if(is_array($arr2))
		{
			if(!empty($arr2[$bigclassname]) && empty($arr[$infofield]))
			{
				$sql3="select * from $tablename where $modulewhere $classidname = '$arr2[$bigclassname]'";
				$arr3=$cjdb->getRow($sql3);
				
				if(is_array($arr3))
				{
					return $arr3;
				}else{
					return $arr2;		
				}
				
			}else{
				return $arr2;	
			}
		}else{
			return $arr;
		}
	
	}else{
		return $arr;	
	}
}

// 获取当前三级栏目配置信息（当前栏目无配置则调用上级配置数据）
function getcolumnconfigdata($configfield='',$jsonok=0,$jsonfield="",$module="article",$otherconfig=array())
{
	global $configinfo;
	
	if($module == "article")
	{
		$moduleclass = $configinfo['moduleclass'];
	}else{
		$moduleclass = getparentclass($otherconfig["tablename"],$otherconfig["columnid"],$otherconfig['classid'],$otherconfig['bigclassname']);
	}
	
	// 新增模块一级栏目参数配置
	if(!empty($moduleclass['class1'][$configfield]))
	{
		if($jsonok == 1)
		{
			$jsonconfigdata = getjsonarr($moduleclass['class1'][$configfield]);
			$configdata = $jsonconfigdata[$jsonfield];
		}else{
			$configdata = $moduleclass['class1'][$configfield];	
		}
	}
	// 新增模块二级栏目参数配置
	if(!empty($moduleclass['class2'][$configfield]))
	{
		if($jsonok == 1)
		{
			$jsonconfigdata = getjsonarr($moduleclass['class2'][$configfield]);
			$configdata = $jsonconfigdata[$jsonfield];
		}else{
			$configdata = $moduleclass['class2'][$configfield];	
		}
	}
	// 新增模块三级栏目参数配置
	if(!empty($moduleclass['class3'][$configfield]))
	{
		if($jsonok == 1)
		{
			$jsonconfigdata = getjsonarr($moduleclass['class3'][$configfield]);
			$configdata = $jsonconfigdata[$jsonfield];
		}else{
			$configdata = $moduleclass['class3'][$configfield];	
		}
	}
	
	return $configdata;
}

// 获取当前配置模块ID
// outmodule 是否外部模块
// outtopid 外部模块配置栏目id
function gettopid($topid=0,$modname="default",$outmodule=0,$outtopid=0)
{
	global $configinfo,$supplier_id;
	
	$topid = !empty($topid) ? $topid : $configinfo['moduleid'];// 当前模块ID
	$modulename = !empty($modname) && $modname != "default" ? $modname."_module" : "module";
	
	// 获取商家配置模块栏目参数信息
	$suppliermodule = "";
	if($supplier_id)
	{
		if($supplier_id)
		{
			$suppliermodule = "supplier";
		}
		if($configinfo['webuser'] == "xcx")
		{
			$suppliermodule = "xcxsupplier";
		}
		if($configinfo['modulepara'] != "admin")
		{
			$suppliermodule = "usersupplier";
		}
	}
	
	// 新增外部模块栏目参数配置
	if($outmodule)
	{
		$topid = $outtopid;
	}else{
		// 新增模块二级栏目参数配置
		if(isset($configinfo['moduleclass']['class2'][$configinfo['cat_id']]))
		{
			$columnid = $configinfo['moduleclass']['class2'][$configinfo['cat_id']];
			if(isset($configinfo[$modulename][$suppliermodule.$columnid]))
			{
				$topid = $columnid;
			}
		}
		// 新增模块三级栏目参数配置
		if(isset($configinfo['moduleclass']['class3'][$configinfo['cat_id']]))
		{
			$columnid = $configinfo['moduleclass']['class3'][$configinfo['cat_id']];
			if(isset($configinfo[$modulename][$suppliermodule.$columnid]))
			{
				$topid = $columnid;
			}
		}
	}
	
	// 获取商家配置模块栏目参数信息
	if($supplier_id)
	{
		if(ifstr($topid,"supplier") == 0)
		{
			$topid = "supplier".$topid;
		}
		// 新增小程序商家模块参数信息 DATE：2019-12-25 START
		if($configinfo['webuser'] == "xcx")
		{
			if(ifstr($topid,"xcxsupplier") == 0)
			{
				$topid = delthstr($topid,"supplier","");
				$topid = "xcxsupplier".$topid;
			}
		}
		// 新增小程序商家模块参数信息 DATE：2019-12-25 END
		
		// 新增会员中心商家模块参数信息 DATE：2020-6-24 START
		if($configinfo['modulepara'] != "admin")
		{
			if(ifstr($topid,"usersupplier") == 0)
			{
				$topid = delthstr($topid,"supplier","");
				$topid = "usersupplier".$topid;
			}
		}
		// 新增会员中心商家模块参数信息 DATE：2020-6-24 END
	}
		
	return $topid;
}

// 获取外部配置栏目ID
// outtopid 外部模块配置栏目ID
function getouttopid($outtopid=0)
{
	global $configinfo;
	
	// 模块信息配置 DATE：2020-5-11 START
	$topid = $outtopid;
	// 模块信息配置 DATE：2020-5-11 END
	
	if($topid)
	{
		$moduleclass = getparentclass($configinfo["ecs_article_cat"],$topid,$configinfo['cat_id'],$configinfo['parent_id']);
	}else{
		$moduleclass = $configinfo['moduleclass'];
	}
	
	// 新增模块一级栏目参数配置
	if(isset($moduleclass['class1'][$configinfo['cat_id']]))
	{
		$columnid = $moduleclass['class1'][$configinfo['cat_id']];
		if(isset($configinfo['module'][$columnid]))
		{
			$topid = $columnid;
		}
	}
	// 新增模块二级栏目参数配置
	if(isset($moduleclass['class2'][$configinfo['cat_id']]))
	{
		$columnid = $moduleclass['class2'][$configinfo['cat_id']];
		if(isset($configinfo['module'][$columnid]))
		{
			$topid = $columnid;
		}
	}
	// 新增模块三级栏目参数配置
	if(isset($moduleclass['class3'][$configinfo['cat_id']]))
	{
		$columnid = $moduleclass['class3'][$configinfo['cat_id']];
		if(isset($configinfo['module'][$columnid]))
		{
			$topid = $columnid;
		}
	}
	
	return $topid;
}

// 获取对应栏目的配置信息
// topid 当前配置栏目ID
// modname 配置栏目名
function gettopmodule($topid=0,$modname="")
{
	global $configinfo;
	
	$topid = !empty($topid) ? $topid : $configinfo['moduleid'];// 当前模块ID
	$modname = $modname ? $modname."_module" : "module";
	
	if(is_array($configinfo[$modname][$topid]))
	{
		$topconfig = $configinfo[$modname][$topid];
		$topconfig['defok'] = 0;
	}else{
		$topconfig = $configinfo[$modname]['default'];	
		$topconfig['defok'] = 1;
	}
	
	return $topconfig;
}

// 获取对应模块钩子的配置数据
// blockname 当前配置块名
// data 配置数据信息
function gethookmoduledata($blockname='',$data="")
{
	global $configinfo;
	
	$moduledata = "";
	
	// 当前模块存在时加载调用配置当前模块程序
	if($configinfo['modulename'])
	{
		$moduledata = modulehookdata("article_".$blockname."_".$configinfo['modulename'],$data);
	}
	
	return $moduledata;
}

// 获取模板数据 追加或覆盖
// datahtml 数据HTML
// tpldatahtml 模板数据HTML
function gettpldata($datahtml='',$tpldatahtml='')
{
	global $configinfo;
	
	$datahtml = is_array($tpldatahtml) ? $tpldatahtml['datahtml'] : $datahtml.$tpldatahtml;
	
	return $datahtml;
}

// 获取当前模块模板开启配置
function gettplok($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$tplok = $topmodule_module['tpl'];

	return $tplok;
}

// 获取当前配置模块目录
function getmodulename($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$modulename = $topmodule_module['module'];

	return $modulename;
}

// 获取当前后台模板配置信息
function getadmintplconfig($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$admintpl = $topmodule_module['admintpl'];

	return $admintpl;
}

// 获取自定义栏目参数HTML
function getcolumnparahtml($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$columnparahtml = $topmodule_module['columnparahtml'];

	return $columnparahtml;
}

// 获取推荐参数名称
function getrecparametername($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$rpnamearr = $topmodule_module['rcontent'];
	
	return $rpnamearr;
}

// 获取参数名称
/* 使用方法：$topid = gettopclass('ecs_article_cat', $cat_id, 'cat_id', 'parent_id');
$pnamearr = getparametername($topid);
$smarty->assign('pname', $pnamearr);*/
function getparametername($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$pnamearr = $topmodule_module['content'];
	
	return $pnamearr;
}

// 获取前台模块模板配置
function getparametersmarty($topid=0, $type="")
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getauthor = $topmodule_module['author'];
	
	if(!empty($getauthor))
	{
		$arr = $getauthor;
		if(is_array($arr))
		{
			if($type == 'detail')
			{
				if(!empty($arr[1]))$smarty = $arr[1];
			}else{
				if(!empty($arr[0]))$smarty = $arr[0];
			}
		}else{
			$smarty = $arr;	
		}
	}

	return $smarty;
}

// 获取当前模块独立表
function getmoduletable($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid,"moduletable");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END

	// 新增模块程序配置
	$topmodule_moduletable = gettopmodule($topid,"moduletable");
	$moduletable = $topmodule_moduletable['tablename'];

	return $moduletable;
}

// 获取当前模块独立表[标签表]
function getmoduletagtable($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid,"moduletable");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END

	// 新增模块程序配置
	$topmodule_moduletable = gettopmodule($topid,"moduletable");
	$moduletagtable = $topmodule_moduletable['tagtablename'];

	return $moduletagtable;
}

// 获取当前模块独立表[评论表]
function getmodulecommenttable($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid,"moduletable");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END

	// 新增模块程序配置
	$topmodule_moduletable = gettopmodule($topid,"moduletable");
	$modulecommenttable = $topmodule_moduletable['commenttablename'];

	return $modulecommenttable;
}

// 获取当前模块独立表[参数表]
function getmoduleplist($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid,"moduletable");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END

	// 新增模块程序配置
	$topmodule_moduletable = gettopmodule($topid,"moduletable");
	$moduleplist = $topmodule_moduletable['plistname'];

	return $moduleplist;
}

// 获取配置后台文章默认字段
function getdefaultarticlefield($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid,"articlefield");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_articlefield = gettopmodule($topid,"articlefield");
	$defaultfield = $topmodule_articlefield['defaultfield'];
	$listdeffield = $topmodule_articlefield['listdeffield'];
	$otherinfoconfig = $topmodule_articlefield['otherinfoconfig'];

	return array('defaultfield'=>$defaultfield,'listdeffield'=>$listdeffield,'otherinfoconfig'=>$otherinfoconfig);
}

// 获取配置参数分类
function getclasstypedata($topid=0,$outtopid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$outtopid = !empty($outtopid) ? getouttopid($outtopid) : 0;
	$topid = $outtopid ? gettopid($topid,"columnpara",1,$outtopid) : gettopid($topid,"columnpara");
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_columnpara = gettopmodule($topid,"columnpara");
	$defok = $topmodule_columnpara['defok'];
	$classtypedata = $topmodule_columnpara['classtypedata'];
	
	$classtypedatagroup = array();
	$classtypedatagroup['def'] = $defok;
	$classtypedatagroup['data'] = $classtypedata;

	return $classtypedatagroup;
}

// 列表搜索条件字段配置
function getparametersearchname($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getlink = $topmodule_module['link'];
		
	if(!empty($getlink))
	{
		$link = $getlink;
		foreach($link as $key=>$val)
		{
			$parainfo = $val;	
			$paralist[$key]['para'] = $parainfo[0];
			$paralist[$key]['field'] = $parainfo[1];
		}
	}

	return $paralist;
}

// 列表搜索配置
function getparametersearch($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$descriptionhtml = $topmodule_module['description'];	
	
	// 追加动态模板数据 DATE:2020-10-23 START
	global $modulefilter,$getmoduledata;
	$tpldata = array();
	$tpldata['modulefilter'] = $modulefilter;
	$tpldata['getmoduledata'] = $getmoduledata;
	$tpldata['phpvarok'] = $modulefilter;
	$tpldata['phpvarok1'] = $getmoduledata;
	$loadtpl_descriptionhtml = getloadtpldata('descriptionhtml', $tpldata, $descriptionhtml);// 加载模板引擎数据
	if($loadtpl_descriptionhtml['error'] == 0)$descriptionhtml = $loadtpl_descriptionhtml['datacontent'];
	// 追加动态模板数据 DATE:2020-10-23 END
	
	$descriptionhtml = phpvarok($descriptionhtml, $modulefilter, $getmoduledata);

	return $descriptionhtml;
}

// 列表模块参数显示配置
function getparameteradmin($topid=0)
{
	global $cjdb,$configinfo;
		
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getcontentmobile = $topmodule_module['contentmobile'];	
	
	if($getcontentmobile)
	{
		$pnamearr = $getcontentmobile;
		foreach($pnamearr as $key=>$val)
		{
			$parainfo = $val;
			$pnamelist[$key]['name'] = $parainfo[1];
			$pnamelist[$key]['para'] = $parainfo[0];
			$pnamelist[$key]['width'] = $parainfo[2];
			$pnamelist[$key]['class'] = $parainfo[3];
		}
	}

	return $pnamelist;
}

// 列表模块参数值配置
function getparameteradminvalue($topid=0)
{
	global $cjdb,$configinfo;
		
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getpvalue = $topmodule_module['pvalue'];	

	return $getpvalue;
}

// 列表模块数据显示HTML配置
function getadminlistdatahtml($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getlistdatahtml = $topmodule_module['listdatahtml'];	

	return $getlistdatahtml;
}

// 列表模块数据扩展显示HTML配置
function getadminlistexphtml($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getlistexphtml = $topmodule_module['listexphtml'];	
	
	// 追加动态模板数据 DATE:2020-10-23 START
	global $modulefilter,$getmoduledata;
	$tpldata = array();
	$tpldata['modulefilter'] = $modulefilter;
	$tpldata['getmoduledata'] = $getmoduledata;
	$tpldata['phpvarok'] = $modulefilter;
	$tpldata['phpvarok1'] = $getmoduledata;
	$loadtpl_getlistexphtml = getloadtpldata('getlistexphtml', $tpldata, $getlistexphtml);// 加载模板引擎数据
	if($loadtpl_getlistexphtml['error'] == 0)$getlistexphtml = $loadtpl_getlistexphtml['datacontent'];
	// 追加动态模板数据 DATE:2020-10-23 END
	
	$getlistexphtml = phpvarok($getlistexphtml, $modulefilter, $getmoduledata);

	return $getlistexphtml;
}

// 详情模块数据扩展显示HTML配置
function getadmincontentexphtml($topid=0)
{
	global $cjdb,$configinfo;
	
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getcontentexphtml = $topmodule_module['contentexphtml'];	
	
	// 追加动态模板数据 DATE:2020-10-23 START
	global $getmoduledata,$getmoduleother;
	$tpldata = array();
	$tpldata['getmoduledata'] = $getmoduledata;
	$tpldata['getmoduleother'] = $getmoduleother;
	$tpldata['phpvarok'] = $getmoduledata;
	$tpldata['phpvarok1'] = $getmoduleother;
	$loadtpl_getcontentexphtml = getloadtpldata('getcontentexphtml', $tpldata, $getcontentexphtml);// 加载模板引擎数据
	if($loadtpl_getcontentexphtml['error'] == 0)$getcontentexphtml = $loadtpl_getcontentexphtml['datacontent'];
	// 追加动态模板数据 DATE:2020-10-23 END
	
	$getcontentexphtml = phpvarok($getcontentexphtml, $getmoduledata, $getmoduleother);

	return $getcontentexphtml;
}

// 获取列表关联信息
function getparameterattr($topid=0)
{
	global $cjdb,$configinfo;
		
	// 新增模块多级栏目参数配置 DATE:2020-4-28 START
	$topid = gettopid($topid);
	// 新增模块多级栏目参数配置 DATE:2020-4-28 END
	
	// 新增模块程序配置
	$topmodule_module = gettopmodule($topid);
	$getauthor_email = $topmodule_module['author_email'];	
		
	if(isset($getauthor_email))
	{
		$author_email = $getauthor_email;
	}

	return $author_email;
}
?>